import re

srcPath = "pytext.txt"
targetPath = "target.txt"


def readfile():
    with open(targetPath, 'w', encoding="utf-8") as fw:
        with open(srcPath, encoding="utf-8") as fr:
            lines = fr.readlines()
            for line in lines:
                s = re.split("(\d{8})", line)
                ss = str.format(f'{transr(s[1])}("{s[1]}", "{s[2].strip()}"), \n')
                fw.write(ss)


def testRe():
    line = "00254038	某商户产品号新用户银行卡1个自然日内累计交易次数超限 您在该商户30天内累计交易次数超限"
    s = re.split("(\d{8})", line)
    print(s)
    ss = str.format(f'{transr(s[1])}("{s[1]}", "{s[2].strip()}")')
    print(ss)


dic = dict(zip('0123456789', ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']))


def transr(ss):
    sss = []
    for s in ss:
        sss.append(dic.get(s))
    return "".join(sss)


if __name__ == "__main__":
    print("ok")
    # testRe()
    readfile()
